/*
 * Miccsnookersim, a snooker simulation with AI
 * Copyright (C) 2009 Enno Ruijters, Frans van den Heuvel, Yannick Thimister,
 * Ali B. Ozmen, Esther Verhoef, Achim Leydecker
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.io.*;

public class Log
{
	private static DataOutputStream dataStream;

	static {
		try {
			FileOutputStream tmp = new FileOutputStream("log.txt");
			dataStream = new DataOutputStream(tmp);
		} catch (Exception e) { }
	}

	public static void logMessage(String message)
	{
		try {
			dataStream.writeBytes("T(" + (message.length() + 2) + "): ");
			dataStream.writeBytes(message);
			dataStream.writeByte('\n');
		} catch (Exception e) { }
	}

	public static void logDouble(double data)
	{
		try {
			dataStream.writeBytes("D:\n");
			dataStream.writeDouble(data);
			dataStream.writeByte('\n');
			dataStream.flush();
		} catch (Exception e) { }
	}

	public static void logVector(Vector data)
	{
		double[] tmp = data.getElements();
		try {
			dataStream.writeBytes("V:");
			dataStream.writeDouble(tmp[0]);
			dataStream.writeDouble(tmp[1]);
			dataStream.writeDouble(tmp[2]);
			dataStream.writeByte('\n');
			dataStream.flush();
		} catch (Exception e) { }
	}
}
